package 算法.leetcode.array;

import com.alibaba.fastjson.JSON;


/**
 * 转换矩阵
 *
 * @author lchenglong
 * @date 2020/10/19
 */
public class ZhuanHuanJuzhen implements Cloneable{

    public static void main(String[] args) {
        int[][] A = new int[][]{{1,2,3},{4,5,6},{7,8,9}};
        System.out.println(JSON.toJSONString(transpose(A)));


    }

    public static int[][] transpose(int[][] A) {
        int l0 = A.length;
        int l1 = A[0].length;
        int[][] B = new int[l1][l0];
        for (int i=0;i<l0;i++) {
            for (int j=0;j<l1;j++) {
                B[j][i] = A[i][j];
            }
        }
        return B;
    }



}
